<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>lin2svm.m</title>
<link rel="stylesheet" type="text/css" href="../../m-syntax.css">
</head>
<body>
<code>
<span class=defun_kw>function</span>&nbsp;<span class=defun_out>svm_model&nbsp;</span>=&nbsp;<span class=defun_name>lin2svm</span>(<span class=defun_in>kfe_model,&nbsp;lin_model</span>)<br>
<span class=h1>%&nbsp;LIN2SVM&nbsp;Merges&nbsp;linear&nbsp;rule&nbsp;and&nbsp;kernel&nbsp;projection.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>%&nbsp;&nbsp;svm_model&nbsp;=&nbsp;lin2svm(kfe_model,lin_model)</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>%&nbsp;&nbsp;This&nbsp;function&nbsp;merges&nbsp;kernel&nbsp;feature&nbsp;extraction&nbsp;model</span><br>
<span class=help>%&nbsp;&nbsp;(data-type&nbsp;kernel&nbsp;projection)&nbsp;and&nbsp;linear&nbsp;classifier&nbsp;to&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;create&nbsp;kernel&nbsp;(SVM)&nbsp;classifier.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Input:</span></span><br>
<span class=help>%&nbsp;&nbsp;kfe_model&nbsp;[struct]&nbsp;Kernel&nbsp;data&nbsp;projection:</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.Alpha&nbsp;[nsv&nbsp;x&nbsp;new_dim]&nbsp;Weight&nbsp;vector.</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.b&nbsp;[new_dim&nbsp;x&nbsp;1]&nbsp;Biases.</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.oprions.ker&nbsp;[string]&nbsp;Kernel&nbsp;identifier&nbsp;(see&nbsp;'help&nbsp;kernel').</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.options.arg&nbsp;[1xnargs]&nbsp;Kernel&nbsp;arguments.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;lin_model&nbsp;[struct]&nbsp;Linear&nbsp;classifier:</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.W&nbsp;[dim&nbsp;x&nbsp;nfun]&nbsp;Weight&nbsp;vector(s).</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.b&nbsp;[nfun&nbsp;x&nbsp;1]&nbsp;Bias(es).</span><br>
<span class=help>%&nbsp;&nbsp;</span><br>
<span class=help>%&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>%&nbsp;&nbsp;svm_model&nbsp;[struct]&nbsp;Kernel&nbsp;classifer:</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.Alpha&nbsp;[nsv&nbsp;x&nbsp;nfun]&nbsp;Weight&nbsp;vector(s).</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.b&nbsp;[nfun&nbsp;x&nbsp;1]&nbsp;Bias(es).</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;.options&nbsp;[struct]&nbsp;Copy&nbsp;of&nbsp;kfe_model.options.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Example:</span></span><br>
<span class=help>%&nbsp;&nbsp;data&nbsp;=&nbsp;load('riply_trn');</span><br>
<span class=help>%&nbsp;&nbsp;options&nbsp;=&nbsp;struct('ker','rbf','arg',1,'new_dim',10);</span><br>
<span class=help>%&nbsp;&nbsp;kpca_model&nbsp;=&nbsp;greedykpca(data.X,options);</span><br>
<span class=help>%&nbsp;&nbsp;proj_data&nbsp;=&nbsp;kernelproj(data,kpca_model);</span><br>
<span class=help>%&nbsp;&nbsp;lin_model&nbsp;=&nbsp;fld(proj_data);</span><br>
<span class=help>%&nbsp;&nbsp;kfd_model&nbsp;=&nbsp;lin2svm(kpca_model,lin_model);</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;ppatterns(data);&nbsp;pboundary(kfd_model);</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;See&nbsp;also&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;LIN2QUAD,&nbsp;SVMCLASS,&nbsp;LINCLASS.</span><br>
<span class=help>%</span><br>
<hr>
<span class=help1>%&nbsp;<span class=help1_field>(c)</span>&nbsp;Statistical&nbsp;Pattern&nbsp;Recognition&nbsp;Toolbox,&nbsp;(C)&nbsp;1999-2003,</span><br>
<span class=help1>%&nbsp;Written&nbsp;by&nbsp;Vojtech&nbsp;Franc&nbsp;and&nbsp;Vaclav&nbsp;Hlavac,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.cvut.cz"&gt;Czech&nbsp;Technical&nbsp;University&nbsp;Prague&lt;/a&gt;,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.feld.cvut.cz"&gt;Faculty&nbsp;of&nbsp;Electrical&nbsp;engineering&lt;/a&gt;,</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://cmp.felk.cvut.cz"&gt;Center&nbsp;for&nbsp;Machine&nbsp;Perception&lt;/a&gt;</span><br>
<br>
<span class=help1>%&nbsp;<span class=help1_field>Modifications:</span></span><br>
<span class=help1>%&nbsp;10-jun-2004,&nbsp;VF</span><br>
<span class=help1>%&nbsp;02-Feb-2003,&nbsp;VF</span><br>
<br>
<hr>
svm_model.Alpha&nbsp;=&nbsp;kfe_model.Alpha*lin_model.W;<br>
svm_model.b&nbsp;=&nbsp;lin_model.b+lin_model.W'*kfe_model.b;<br>
<br>
svm_model.sv.X&nbsp;=&nbsp;kfe_model.sv.X;<br>
svm_model.nsv&nbsp;=&nbsp;size(svm_model.sv.X,2);<br>
svm_model.options&nbsp;=&nbsp;kfe_model.options;<br>
svm_model.fun&nbsp;=&nbsp;<span class=quotes>'svmclass'</span>;<br>
<br>
<span class=jump>return</span>;<br>
<span class=comment>%&nbsp;EOF</span><br>
</code>
